-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
avoid BASIC_DATA branch edit for free in existent accounts #513
Conversation
Signed-off-by: Ignacio Hagopian <[email protected]>
// Note that we do a write-event in CodeHash without distinguishing if the tx target account | ||
// exists or not. Pre-7702, there's no situation in which an existing codeHash can be mutated, thus | ||
// doing a write-event shouldn't cause an observable difference in gas usage. | ||
// TODO(7702): re-check this in the spec and implementation to be sure is a correct solution after | ||
// EIP-7702 is implemented. | ||
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, true, nil) | ||
aw.touchAddressAndChargeGas(targetAddr, zeroTreeIndex, utils.CodeHashLeafKey, false, nil) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverting this to the way it was pre-yesterday PR. (Still keeping the renaming since it was a useful change).
st.evm.Accesses.TouchTxTarget(targetAddr.Bytes(), msg.Value.Sign() != 0) | ||
if !st.state.Exist(*targetAddr) { | ||
st.evm.Accesses.TouchCodeHash(targetAddr.Bytes(), true, nil, false) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out that the logic I made yesterday reg CODEHASH being immutable (before 7702) was fine. But this free CODEHASH write we did before is also giving for free a BRANCH_EDIT unconditionally.
This means that for existing addresses, the unconditional free write-event on CODEHASH made writes in BASIC_DATA cheaper (since CODEHASH got that for free, which attempted to be a simplification but is wrong).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Fixing a problem I found when filling the test now, I'll explain in comments.
cc @tanishqjasoria